#ifndef COIN_SBSTRING_H
#define COIN_SBSTRING_H

/**************************************************************************\
 *
 *  This file is part of the Coin 3D visualization library.
 *  Copyright (C) by Kongsberg Oil & Gas Technologies.
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License
 *  ("GPL") version 2 as published by the Free Software Foundation.
 *  See the file LICENSE.GPL at the root directory of this source
 *  distribution for additional information about the GNU GPL.
 *
 *  For using Coin with software that can not be combined with the GNU
 *  GPL, and for taking advantage of the additional benefits of our
 *  support services, please contact Kongsberg Oil & Gas Technologies
 *  about acquiring a Coin Professional Edition License.
 *
 *  See http://www.coin3d.org/ for more information.
 *
 *  Kongsberg Oil & Gas Technologies, Bygdoy Alle 5, 0257 Oslo, NORWAY.
 *  http://www.sim.no/  sales@sim.no  coin-support@coin3d.org
 *
\**************************************************************************/


#include <Inventor\C\basic.h>

class SbIntList;


class COIN_DLL_API SbString 
{ 
private:
  struct impl;
  impl* pimpl_;

public:
  SbString(); 
  SbString(const SbString & s);
  SbString(const char * s);
  SbString(const char * s, int start, int last);
  SbString(const int digits);
  ~SbString();

  SbString& sprintf(const char * formatstr, ...);
  SbString& vsprintf(const char * formatstr, va_list& args);
  SbString& operator=(const SbString & s);
  SbString& operator=(const char * s);

  SbString& operator+=(const char * s);
  SbString& operator+=(const SbString & s);
  SbString& operator+=(const char c);

  void makeEmpty();
  void deleteSubString(int startidx, int lastidx);
  void addIntString(const int value);

  SbString      getSubString(int startidx) const;
  SbString      getSubString(int startidx, int lastidx) const;
  SbString      lower() const;
  SbString      upper() const;

  uint32_t      hash(void) const; 
  int           getLength(void) const; 
  const char*   getString() const;   char          operator[](int index) const; 
  int           compare(const SbString& str) const;
  int           compare(const char * str, int offset) const;
  int           compare(const char * str) const { return compare(str, 0); }
  int           compareSubString(const char * str, int offset) const;
  int           compareSubString(const char * str) const { return compareSubString(str, 0); }

  int           find(const SbString & s) const;
  SbBool        findAll(const SbString & strarg, SbIntList & found) const;
};


inline int operator==(const SbString & str1, const SbString & str2) { return str1.compare(str2.getString()) == 0;  }
inline int operator!=(const SbString & str1, const SbString & str2) { return str1.compare(str2.getString()) != 0;  }

inline int operator==(const SbString & str1, const char * str2) { return str1.compare(str2) == 0;  }
inline int operator!=(const SbString & str1, const char * str2) { return str1.compare(str2) != 0;  }

inline int operator==(const char * str1, const SbString & str2) { return str2.compare(str1) == 0;  }
inline int operator!=(const char * str1, const SbString & str2) { return str2.compare(str1) != 0;  }

inline SbString operator+(const SbString & str1, const SbString & str2) { return SbString(str1) += str2; }
inline SbString operator+(const SbString & str1, const char * str2) { return SbString(str1) += str2; }
inline SbString operator+(const char * str1, const SbString & str2) { return SbString(str2) += str1; }


#ifndef COIN_INTERNAL
// For Open Inventor compatibility.
#include <Inventor/SbName.h>
#endif // !COIN_INTERNAL

#endif // !COIN_SBSTRING_H
